
<head th:fragment="headerCss">
    <meta charset="utf-8">
    <title>竞赛管理平台</title>
    <meta content="width=device-width, initial-scale=1.0" name=	"viewport">
    <meta name="keywords" content="" />
    <meta name="description"
          content="竞赛管理平台" />
    <link rel="stylesheet" href="/js/layui/css/layui.css" >
    <!-- Bootstrap CSS File -->
    <link href="/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="/css/examination/common.css" >
    <link rel="shortcut icon" href="favicon.ico">
    <style type="text/css">
        #butt {
            width: 150px;
            height: 58px;
            font-size: 30px;
            line-height: 58px;
            color: #440000;
            background: #dd8e4f;
            border: 1px solid #ff6600;
            text-align: center;
            cursor: default;
        }
        #box {
            overflow: hidden;
            width: 0;
            height: 0;
        }
        #test {
            width: 100%;
            height: 100%;
            border-style: none;
        }

        #layui-layer1 .layui-layer-btn{
            text-align: center;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn0{
            background: #FF6A66;
            color: #fff;
            border: none;
            font-size: 14px;
        }

        #layui-layer1 .layui-layer-btn .layui-layer-btn1{
            background: white;
            border:1px solid #FF6A66;
            font-size: 14px;
        }
        #infoBox{
            background: #fff !important;
            box-shadow: 0px 3px 6px 1px rgba(181,197,223,0.1);
            -moz-box-shadow: 0px 3px 6px 1px rgba(181,197,223,0.1);
            -webkit-box-shadow: 0px 3px 6px 1px rgba(181,197,223,0.1);
            -ms-box-shadow: 0px 3px 6px 1px rgba(181,197,223,0.1);
        }
        #ticketNumber, #idCard, #name {
            color: #000;
            text-align: center;
            line-height: 64px;
            float: left;
            margin-bottom: 0;
            font-size: 14px;
        }
    </style>
</head>
<body class="signin">
<div class="infoBox" id="infoBox">
    <div class="info">
        <div class="redlogo"><img src="/img/jinzhuan.png"></div>
        <div class="attributes">
            <h1 id="roomNumber"></h1>
            <h1 id="seatNumber"></h1>
            <h1 id="name"></h1>
        </div>
    </div>
</div>
<div class="main_content">
    <div class="window_box resetCss">
        <div class="loginIn resetLoginIn">
            <h1 id="eaxmName"></h1>

            <div class="optimize">

                <div class="btnColor" style="margin-left: 170px;margin-top: 40%">
                    <input class="btn btn-block not-allowed" id="sub"  readonly onclick="login();" value="开始考试"/>
                </div>
            </div>

        </div>
    </div>
</div>
<!--<div id="box">-->
<!--<iframe src="/examination/exam" id="test"></iframe>-->
<!--</div>-->
<div id="lookView" style="display: none;padding: 20px">
    <p id="examNotes"></p>
</div>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v='2.1.4'}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">

    document.oncontextmenu=new Function("event.returnValue=false");
    document.onselectstart=new Function("event.returnValue=false");

    //f12、f11禁用
    document.onkeydown = function (e) {
        var ev = window.event || e;
        var code = ev.keyCode || ev.which;
        if (123 || 122 ||  115) {
            if(ev.preventDefault) {
                ev.preventDefault();
            } else {
                ev.keyCode = 0;
                ev.returnValue = false;
            }
        }
    };

    function lookView() {
        layer.open({
            title: '考试须知',
            type: 1,
            area: ['1000px', '600px'],
            fixed: false, //不固定
            maxmin: true,
            content: $("#lookView"),
            end: function () {
            },
            success: function () {
            }
        });
    }
    //倒计时
    $(function () {
        if(window.localStorage){
            var times =JSON.parse(window.localStorage.getItem("times"));
            $('#times').text('15');
            var times1 = times * 60;
            var intro = JSON.parse(window.localStorage.getItem("intro"));
            var info = JSON.parse(window.localStorage.getItem("info"));
            $("#startTime").html(intro.startTime);
            //监督员设置了延时
            if(info.endDate !=undefined){
                $("#endTime").html(info.endDate);
            }else{
                $("#endTime").html(intro.endTime);
            }

            $("#time").html("考试时长："+intro.duration+"分钟");
            $("#examNotes").html(intro.examNotes);
            // $("#name").html("姓名："+info.name);
            $("#name").html("二次加密："+info.num2);

            //$("#roomNumber").html("考场号："+info.roomNumber);
            //$("#seatNumber").html("座位号："+info.seatNumber);
        }else{
            layer.msg("请换浏览器，最佳为谷歌")
        }
        $.ajax({
            url: "/jzApi/examinations/selExaminationPaper",
            type:'POST',
            data:{id:JSON.parse(window.localStorage.getItem("intro")).id},
            success: function (r) {
                $("#eaxmName").html(intro.name);
                if(window.localStorage){
                    window.localStorage.setItem("exam.html",JSON.stringify(r.data));
                }else{
                    layer.msg("请换浏览器，最佳为谷歌")
                }
            }
        });

        $.ajax({
            type: "POST",
            url: "/jzApi/examinations/getNowDateTime",
            data: {},
            success: function (r) {
                //console.log("map =" , r.data.endTime);
                window.localStorage.setItem("nowDate",r);
                countDown();
            }
        });

        function addZero(i) {
            return i < 10 ? "0" + i: i + "";
        }
        function countDown() {
        }
    });

    function login() {
        let set ;
        let time = 5;

        set = setInterval(function (){
            $('#sub').attr("disabled",true).css({"background":'#999'}).val('开始考试'+time+"s");
            time--;
            if( time < 0 ){
                $('#sub').attr({"disabled":false,'style':''}).val('开始考试');
                clearInterval(set)
            }
        },1000)

        var info = JSON.parse(window.localStorage.getItem("info"));
        var intro = JSON.parse(window.localStorage.getItem("intro"));
        $.ajax({
            type: "POST",
            url: "/jzApi/examinations/examerification",
            data: {
                id: info.cbatchId,
                type:intro.type
            },
            success: function (r) {
                //console.log("map =" , r.data.endTime);
                if( r.code == 0 ){
                    location.href='/examination/exam';
                }else{
                    layer.msg(r.msg)
                }
            }
        });

        // if (!$('#radio').prop("checked")) {
        //     layer.msg("请勾选已同意");
        //     return false
        // }
        // window.open('/examination/exam', '考试', 'left=0,top=0,width='+ (screen.availWidth - 10) +',height='+ (screen.availHeight-50) +',menubar=no,fullscreen=yes,location=no' )

        // var info = JSON.parse(window.localStorage.getItem("info"));
        // var startTime = new Date(intro.startTime).getTime() + (60*15*1000);
        // var thisTime = new Date( window.localStorage.getItem("nowDate").replace(/-/g,"/") ).getTime();

        // if( info.state == "8" ){
        //     location.href='/examination/exam';
        // }
        //
        // if( startTime > thisTime ){
        //     $.ajax({
        //         url: "/jzApi/examinations/changeState",
        //         type:'POST',
        //         data:{id:JSON.parse(window.localStorage.getItem("info")).stuSignId},
        //         success: function (r) {
        //             if(r)
        //             {
        //                 location.href='/examination/exam';
        //             }else{
        //                 alert("请重新登录！");
        //             }
        //         }
        //     });
        // }else{
        //     layer.msg('超过15分钟不可进入考试')
        // }

    }

</script>

</body>





